package com.naiterui.ehp.bs.patient.controller.inner;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BaseExceptionCodes;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.wechat.constants.WeChatConstant;
import com.naiterui.ehp.bs.wechat.service.ICustomMsgApiService;
import com.naiterui.ehp.bs.wechat.service.IMediaApiService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客服消息
 *
 * @author yangfuya
 * @version 1.0
 * @date 2021-02-27 11:27
 **/
@Api(tags = {SwaggerTag.PATIENT + SwaggerTag.INNER_API + SwaggerTag.CUSTOM_MSG})
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "ap/inner/custom")
public class ApInnerCustomMsgApiController {
    private final ICustomMsgApiService customMsgApiService;
    private final IMediaApiService mediaApiService;

    @PostMapping("/sendSystemMsg")
    public ResponseVO<Void> sendSystemMsg(String openId, String content) {
        this.customMsgApiService.sendSystemMsg(openId, content);
        return PublicService.returnResponseVO(BaseExceptionCodes.SUCCESS);
    }

    @PostMapping("/sendMiniProgramMsg")
        public ResponseVO<Void> sendMiniProgramMsg(String openId, String title, String appId, String pagePath, String thumbMediaId) {
        this.customMsgApiService.sendMiniProgramMsg(openId, title, appId, pagePath, thumbMediaId);
        return PublicService.returnResponseVO(BaseExceptionCodes.SUCCESS);
    }

    @PostMapping("/uploadThumbMedia")
    public ResponseVO<String> uploadThumbMedia(String filePath) {
        return PublicService.returnResponseVO(this.mediaApiService.uploadMedia(WeChatConstant.MediaFileType.THUMB, filePath));
    }
}
